package cn.kgm.bio.singleLink;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket server = new ServerSocket(6666);
        Socket accept;
        while (true){
            // 在这里等待客户端链接，链接成功时会创建一个socket用于通信
            accept = server.accept();
            InputStream is = accept.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String line;
            while ((line = br.readLine()) != null){
                System.out.println("服务端收到，"+ line);
            }
        }

    }
}
